<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<%@ taglib prefix="C" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>发布帖子-CAS官网</title>
		<link rel="stylesheet" href="css/iconfont.css" />
		<link rel="shortcut icon" href="img/favicon.ico" />
		<link rel="stylesheet" href="css/admin.css" />
		<link rel="stylesheet" href="css/publishpost.css" />
		<script type="text/javascript" src="js/jquery-3.2.0.min.js"></script>
		<script type="text/javascript" charset="utf-8" src="ueditor/ueditor.config.js"></script>
		<script type="text/javascript" charset="utf-8" src="ueditor/ueditor.all.min.js"></script>
		<!--建议手动加在语言，避免在ie下有时因为加载语言失败导致编辑器加载失败-->
		<!--这里加载的语言文件会覆盖你在配置项目里添加的语言类型，比如你在配置项目里配置的是英文，这里加载的中文，那最后就是中文-->
		<script type="text/javascript" charset="utf-8" src="ueditor/lang/zh-cn/zh-cn.js"></script>
		<script type="text/javascript" src="js/admin.js"></script>
	</head>

	<body>
		<div class="g-left">
			<ul class="m-nav">
				<C:forEach items="${menulist }" var="menu">
					<C:if test="${menu.permission<=role && menu.permission!=0 }">
						<C:choose>
							<C:when test="${menu.name == '帖子管理' }">
								<li class="m-active">
									<span><i class="icon iconfont">&#xe612;</i>${menu.name }<i class="icon iconfont">&#xe601;</i></span>
									<ul>
										<C:forEach items="${menulist }" var="menu1">
											<C:if test="${menu.id == menu1.pid }">
												<C:choose>
													<C:when test="${menu1.permission<=role && menu.permission!=0 && menu1.name=='发布帖子'}">
														<li class="m-li-active">
															<a href="${menu1.url }">${menu1.name }</a>
														</li>
													</C:when>
													<C:otherwise>
														<li>
															<a href="${menu1.url }">${menu1.name }</a>
														</li>
													</C:otherwise>
												</C:choose>
											</C:if>
										</C:forEach>
									</ul>
								</li>
							</C:when>
							<C:otherwise>
								<C:if test="${menu.pid == 0}">
									<li>
										<span><i class="icon iconfont">&#xe612;</i>${menu.name }<i class="icon iconfont">&#xe601;</i></span>
										<ul>
											<C:forEach items="${menulist }" var="menu1">
												<C:if test="${menu.id == menu1.pid && menu1.permission<=role && menu.permission!=0}">
													<li>
														<a href="${menu1.url }">${menu1.name }</a>
													</li>
												</C:if>
											</C:forEach>
										</ul>
									</li>
								</C:if>
							</C:otherwise>
						</C:choose>
					</C:if>
				</C:forEach>
			</ul>
		</div>
		<div class="g-right">
			<div class="g-status">
				<i class="icon iconfont m-switch">&#xe606;</i>
				<div>
					<i class="icon iconfont m-switch">&#xe602;</i>
					<a href="index.jsp">前台</a>
					<i class="icon iconfont m-switch">&#xe6a0;</i>
					<span>管理员:</span>
					<a href="">张三</a>
					<i class="icon iconfont m-switch">&#xe60e;</i>
					<a href="">安全退出</a>
				</div>
			</div>
			<div class="g-mn">
				<form>
					<div class="m-form-content">
						<div class="m-input">
							<span>标题：</span>
							<input type="text" placeholder="标题" />
							<span>分类</span>
							<select name="">
								<option value="HTML">HTML</option>
							</select>
						</div>
						<div>
							<script id="editor" type="text/plain" style="width:1024px;height:500px;"></script>
						</div>
						<div class="m-input">
							<input type="submit" value="保存" />
							<input type="reset" value="重置" />
						</div>
					</div>
				</form>
			</div>
		</div>

		<script type="text/javascript">
			//实例化编辑器
			//建议使用工厂方法getEditor创建和引用编辑器实例，如果在某个闭包下引用该编辑器，直接调用UE.getEditor('editor')就能拿到相关的实例
			var ue = UE.getEditor('editor');

			function isFocus(e) {
				alert(UE.getEditor('editor').isFocus());
				UE.dom.domUtils.preventDefault(e)
			}

			function setblur(e) {
				UE.getEditor('editor').blur();
				UE.dom.domUtils.preventDefault(e)
			}

			function insertHtml() {
				var value = prompt('插入html代码', '');
				UE.getEditor('editor').execCommand('insertHtml', value)
			}

			function createEditor() {
				enableBtn();
				UE.getEditor('editor');
			}

			function getAllHtml() {
				alert(UE.getEditor('editor').getAllHtml())
			}

			function getContent() {
				var arr = [];
				arr.push("使用editor.getContent()方法可以获得编辑器的内容");
				arr.push("内容为：");
				arr.push(UE.getEditor('editor').getContent());
				alert(arr.join("\n"));
			}

			function getPlainTxt() {
				var arr = [];
				arr.push("使用editor.getPlainTxt()方法可以获得编辑器的带格式的纯文本内容");
				arr.push("内容为：");
				arr.push(UE.getEditor('editor').getPlainTxt());
				alert(arr.join('\n'))
			}

			function setContent(isAppendTo) {
				var arr = [];
				arr.push("使用editor.setContent('欢迎使用ueditor')方法可以设置编辑器的内容");
				UE.getEditor('editor').setContent('欢迎使用ueditor', isAppendTo);
				alert(arr.join("\n"));
			}

			function setDisabled() {
				UE.getEditor('editor').setDisabled('fullscreen');
				disableBtn("enable");
			}

			function setEnabled() {
				UE.getEditor('editor').setEnabled();
				enableBtn();
			}

			function getText() {
				//当你点击按钮时编辑区域已经失去了焦点，如果直接用getText将不会得到内容，所以要在选回来，然后取得内容
				var range = UE.getEditor('editor').selection.getRange();
				range.select();
				var txt = UE.getEditor('editor').selection.getText();
				alert(txt)
			}

			function getContentTxt() {
				var arr = [];
				arr.push("使用editor.getContentTxt()方法可以获得编辑器的纯文本内容");
				arr.push("编辑器的纯文本内容为：");
				arr.push(UE.getEditor('editor').getContentTxt());
				alert(arr.join("\n"));
			}

			function hasContent() {
				var arr = [];
				arr.push("使用editor.hasContents()方法判断编辑器里是否有内容");
				arr.push("判断结果为：");
				arr.push(UE.getEditor('editor').hasContents());
				alert(arr.join("\n"));
			}

			function setFocus() {
				UE.getEditor('editor').focus();
			}

			function deleteEditor() {
				disableBtn();
				UE.getEditor('editor').destroy();
			}

			function disableBtn(str) {
				var div = document.getElementById('btns');
				var btns = UE.dom.domUtils.getElementsByTagName(div, "button");
				for(var i = 0, btn; btn = btns[i++];) {
					if(btn.id == str) {
						UE.dom.domUtils.removeAttributes(btn, ["disabled"]);
					} else {
						btn.setAttribute("disabled", "true");
					}
				}
			}

			function enableBtn() {
				var div = document.getElementById('btns');
				var btns = UE.dom.domUtils.getElementsByTagName(div, "button");
				for(var i = 0, btn; btn = btns[i++];) {
					UE.dom.domUtils.removeAttributes(btn, ["disabled"]);
				}
			}

			function getLocalData() {
				alert(UE.getEditor('editor').execCommand("getlocaldata"));
			}

			function clearLocalData() {
				UE.getEditor('editor').execCommand("clearlocaldata");
				alert("已清空草稿箱")
			}
		</script>
	</body>

</html>